package com.inspur.jzsxxzx.service.catalog.impl;

import com.inspur.jzsxxzx.entity.catalog.DataCatalog;
import com.inspur.jzsxxzx.mapper.catalog.DataCatalogMapper;
import com.inspur.jzsxxzx.service.catalog.DataCatalogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DataCatalogServiceImpl implements DataCatalogService {

    @Autowired
    private DataCatalogMapper dataCatalogMapper;

    @Override
    public int save(DataCatalog record) {
        return dataCatalogMapper.insert(record);
    }

    @Override
    public DataCatalog findById(String cataId) {
        return dataCatalogMapper.selectByPrimaryKey(cataId);
    }

    @Override
    public int update(DataCatalog record) {
        return dataCatalogMapper.updateByPrimaryKey(record);
    }

    @Override
    public int deleteById(String cataId) {
        return dataCatalogMapper.deleteByPrimaryKey(cataId);
    }

    @Override
    public List<DataCatalog> findAll() {
        return dataCatalogMapper.selectAll();
    }

    @Override
    public List<DataCatalog> findByCondition(DataCatalog condition) {
        return dataCatalogMapper.selectByCondition(condition);
    }

    @Override
    public List<DataCatalog> findByPage(DataCatalog condition, int pageNum, int pageSize) {
        int offset = (pageNum - 1) * pageSize;
        return dataCatalogMapper.selectByPage(condition, offset, pageSize);
    }

    @Override
    public int countByCondition(DataCatalog condition) {
        return dataCatalogMapper.countByCondition(condition);
    }

    @Override
    public List<DataCatalog> findByBasicElemCatalogIdAndVersion(String basicElemCatalogId,
            Integer basicElemCatalogVersion) {
        return dataCatalogMapper.selectByBasicElemCatalogIdAndVersion(basicElemCatalogId, basicElemCatalogVersion);
    }
}